package com.example.test_activity.MVP.presenter;

import android.widget.Toast;

import com.example.test_activity.MVP.view.AddCourseActivity;
import com.example.test_activity.MVP.view.IAdd;
import com.example.test_activity.entity.Week;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by 旭 on 2017/5/6/006.
 */

public class AddPresenter implements IAddPresenter {

    IAdd add;

    public AddPresenter(IAdd add)
    {
        this.add = add;
    }

    @Override
    public void doDecide(Week week) {
        int number = 0;
        if (week.getName().equals("")) {
            number = 1;
        }
        else if (week.getOne().equals("")) {
            number = 2;
        }
        else if (week.getTwo().equals("")) {
            number = 3;
        }

        if (week.getFlag().equals("单周")) {
            week.setFlag("1");
        } else if (week.getFlag().equals("双周")) {
            week.setFlag("0");
        } else {
            week.setFlag("2");
        }

        week.setName(week.getName() + "_(" + week.getOne() + "#" + week.getTwo() + ")");

        add.decide(number,week);
    }

    @Override
    public void setCourse(Week week,String weekend,String num) {
        Map<String, String> map = new HashMap<>();

        map.put("name", week.getName());
        map.put("weekend", weekend);
        map.put("num", num);
        map.put("max", week.getMax());
        map.put("min", week.getMin());
        map.put("flag", week.getFlag());
        map.put("one", week.getOne());
        map.put("two", week.getTwo());
        map.put("week", "");
        map.put("cno", "");
        map.put("school", "信息学院");

        add.getCourse(map);
    }
}
